package com.qinggeng.project.system.controller;

import com.google.common.collect.Lists;
import com.qinggeng.common.utils.StringUtils;
import com.qinggeng.framework.security.service.TokenService;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.project.system.domain.SinglePointSale;
import com.qinggeng.project.system.service.SinglePointSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;

import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 配送区域单配送点销量controller
 * @author 吴鹏飞
 * @date 2020/11/17
 */
@RestController
@RequestMapping("/system/singlePointSale")
public class SinglePointSaleController {
    @Autowired
    private SinglePointSaleService singlePointSaleService;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询配送区域单配送点销量列表
     */
    @PreAuthorize("@ss.hasPermi('system:singlePointSale:list')")
    @GetMapping("/list")
    public AjaxResult list(SinglePointSale singlePointSale){
        if(StringUtils.isNotEmpty(singlePointSale.getRecordDate())){
            return AjaxResult.success(singlePointSaleService.listSinglePointSale(singlePointSale));
        }
        return AjaxResult.success(singlePointSaleService.listSinglePointSaleByTime(singlePointSale));
    }

    /**
     * 获取配送区域单配送点销量详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:singlePointSale:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id ){
        SinglePointSale singlePointSale =  singlePointSaleService.selectSinglePointById(id);
        return AjaxResult.success(singlePointSale);
    }


}
